//
//  TravelTVCell.m
//  WildDonkey
//
//  Created by 佟小波 on 15/3/27.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "TravelTVCell.h"
#import "UIImageView+WebCache.h"

@implementation TravelTVCell

- (void)dealloc
{
    [_imgView release];
    [_nameLabel release];
    [_descLabel release];
    [_travel release];
    [super dealloc];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        CGFloat height=self.frame.size.height;
        
        CGRect rect = [UIScreen mainScreen].bounds;
        
        _imgView=[[UIImageView alloc]initWithFrame:CGRectMake(10, 5, rect.size.width-20, height*3.2)];
        //                _imgView.backgroundColor=[UIColor blueColor];
        [self.contentView addSubview:_imgView];
        
        
        
        
        _descLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, _imgView.frame.size.height*0.85, _imgView.frame.size.width, 20)];
        
        _descLabel.backgroundColor=[UIColor blackColor];
        _descLabel.alpha=0.5;
        _descLabel.textAlignment=NSTextAlignmentCenter;
        _descLabel.textColor=[UIColor whiteColor];
        [_imgView addSubview:_descLabel];
        
        
    }
    return self;
}




-(void)setTravel:(Travel *)travel
{
    if (_travel!=travel) {
        [_travel release];
        _travel=[travel retain];
        
        
        _nameLabel.text=_travel.name;
        _descLabel.text=_travel.desc;
        
        
        //NSURL *url=[NSURL URLWithString:travel.img];
        
        
        [_imgView setImageWithURL:[NSURL URLWithString:travel.img]];
        
    }
}

@end
